package cn.b.sky.shop.activiti.model;

import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 
 * <strong>Title : Leave.java<br></strong>
 * <strong>Package : cn.b.sky.shop.activiti.model<br></strong>
 * <strong>Description : </strong>请假测试<br> 
 * <strong>Create on : 2015-10-28 下午3:35:06<br></strong>
 * <p>
 * @author lidapeng<br>
 * @version <strong>v1.0.0</strong><br>
 * <br>
 * <strong>修改历史:</strong><br>
 * 修改人 | 修改日期 | 修改描述<br>
 * -------------------------------------------<br>
 * <br>
 * <br>
 */
public class Leave implements Serializable {
  private static final long serialVersionUID = 1L;

  private Long id;

  /**
   * 唯一键流程业务的ID
   */
  private String businessKey;

  private String processInstanceId;

  private String userId;

  @DateTimeFormat(iso = ISO.DATE_TIME, pattern = "yyyy-MM-dd HH:mm:ss")
  private Date startTime;

  @DateTimeFormat(iso = ISO.DATE_TIME, pattern = "yyyy-MM-dd HH:mm:ss")
  private Date endTime;

  @DateTimeFormat(iso = ISO.DATE_TIME, pattern = "yyyy-MM-dd HH:mm:ss")
  private Date realityStartTime;

  @DateTimeFormat(iso = ISO.DATE_TIME, pattern = "yyyy-MM-dd HH:mm:ss")
  private Date realityEndTime;

  private Date applyTime;

  private String leaveType;

  private String reason;

  //-- 临时属性 --//

  // 流程任务
  private Task task;

  private Map<String, Object> variables;

  // 运行中的流程实例
  private ProcessInstance processInstance;

  private List<Leave> leaves = new ArrayList<Leave>();

  // 历史的流程实例
  private HistoricProcessInstance historicProcessInstance;

  // 流程定义
  private ProcessDefinition processDefinition;

  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getBusinessKey() {
    businessKey = "leave_" + this.id;
    return businessKey;
  }

  public void setBusinessKey(String businessKey) {
    this.businessKey = businessKey;
  }

  public String getProcessInstanceId() {
    return processInstanceId;
  }

  public void setProcessInstanceId(String processInstanceId) {
    this.processInstanceId = processInstanceId;
  }

  public String getUserId() {
    return userId;
  }

  public void setUserId(String userId) {
    this.userId = userId;
  }

  public Date getStartTime() {
    return startTime;
  }

  public void setStartTime(Date startTime) {
    this.startTime = startTime;
  }

  public Date getEndTime() {
    return endTime;
  }

  public void setEndTime(Date endTime) {
    this.endTime = endTime;
  }

  public Date getRealityStartTime() {
    return realityStartTime;
  }

  public void setRealityStartTime(Date realityStartTime) {
    this.realityStartTime = realityStartTime;
  }

  public Date getRealityEndTime() {
    return realityEndTime;
  }

  public void setRealityEndTime(Date realityEndTime) {
    this.realityEndTime = realityEndTime;
  }

  public Date getApplyTime() {
    return applyTime;
  }

  public void setApplyTime(Date applyTime) {
    this.applyTime = applyTime;
  }

  public String getLeaveType() {
    return leaveType;
  }

  public void setLeaveType(String leaveType) {
    this.leaveType = leaveType;
  }

  public String getReason() {
    return reason;
  }

  public void setReason(String reason) {
    this.reason = reason;
  }

  public Task getTask() {
    return task;
  }

  public void setTask(Task task) {
    this.task = task;
  }

  public Map<String, Object> getVariables() {
    return variables;
  }

  public void setVariables(Map<String, Object> variables) {
    this.variables = variables;
  }

  public ProcessInstance getProcessInstance() {
    return processInstance;
  }

  public void setProcessInstance(ProcessInstance processInstance) {
    this.processInstance = processInstance;
  }

  public HistoricProcessInstance getHistoricProcessInstance() {
    return historicProcessInstance;
  }

  public void setHistoricProcessInstance(HistoricProcessInstance historicProcessInstance) {
    this.historicProcessInstance = historicProcessInstance;
  }

  public ProcessDefinition getProcessDefinition() {
    return processDefinition;
  }

  public void setProcessDefinition(ProcessDefinition processDefinition) {
    this.processDefinition = processDefinition;
  }

  public List<Leave> getLeaves() {
    return leaves;
  }

  public void setLeaves(List<Leave> leaves) {
    this.leaves = leaves;
  }

}
